#include "lv_100ask_pinyin_ime.h"
#include "lv_russian_ime.h"
#include "lv_ime_func.h"
#include "lv_japanese_ime.h"
#include "lv_korean_ime.h"
#include "lv_vietnamese_ime.h"
#include "lv_arabic_ime.h"
#include "lv_persian_ime.h"
extern lv_100ask_dict_t lv_100ask_def_japanese_dict[];
extern lv_100ask_dict_t lv_100ask_def_korean_dict[];
extern lv_100ask_dict_t lv_100ask_def_vietnamese_dict[];
ime_plugin_t ime_set[] = {
            //keypad_code               dict                                init_kb_map                     init_dict               input_proc  
        {   LV_KEYPAD_MODE_PINYIN,      NULL,                               init_pinyin_keypad_map,         NULL,                   pinyin_input_proc     },
        {   LV_KEYPAD_MODE_JAPANESE,    lv_100ask_def_japanese_dict,        init_japanese_keypad_map,       init_japanese_dict,     japanese_input_proc   },
        {   LV_KEYPAD_MODE_RUSSIA_LOW,  NULL,                               init_russia_keypad_map,         NULL,                   NULL                  },
        {   LV_KEYPAD_MODE_KOREAN,      lv_100ask_def_korean_dict,          init_korean_keypad_map,         init_korean_dict,       korean_input_proc      },
        {   LV_KEYPAD_MODE_VIETNAMESE,  lv_100ask_def_vietnamese_dict ,     init_vietnamese_keypad_map,     init_vietnamese_dict,   vietnamese_input_proc  },
        {   LV_KEYPAD_MODE_ARABIC    ,  NULL,                               init_arabic_keypad_map,         NULL,                   NULL                  },
        {   LV_KEYPAD_MODE_PERSIAN    , NULL,                               init_persian_keypad_map,         NULL,                   NULL                  },
};

ime_input_proc ime_get_input_pro_func(int mode_code)
{
    printf("all size:%d\n", sizeof(ime_set)/sizeof(ime_set[0]));
    for(int i = 0; i < sizeof(ime_set)/sizeof(ime_set[0]);i++)
    {
        printf("ime_set[i].keypad_code:%d,mode_code:%d\n",ime_set[i].keypad_code,mode_code);
        if(mode_code ==ime_set[i].keypad_code)
        {
            printf("ime_get_input_pro_func mode_code(%d),fun:%d\n",mode_code,ime_set[i].input_proc);
            printf("ime_get_input_pro_func %d,%d,%d,%d,%d\n",ime_set[i].keypad_code,ime_set[i].dict,ime_set[i].init_dict,ime_set[i].init_kb_map,ime_set[i].input_proc);
            return ime_set[i].input_proc;
        }
    }
    return NULL;
}

int lv_ime_init_multi_plugin(lv_obj_t * kb)
{
    for(int i=0;i<sizeof(ime_set)/sizeof(ime_set[0]);i++)
    {
        if(ime_set[i].init_kb_map)
        {
            ime_set[i].init_kb_map(kb);
        }
        if(ime_set[i].init_dict && ime_set[i].dict)
        {
            ime_set[i].init_dict(NULL,ime_set[i].dict);
        }
    }
    return 0;
}


lv_obj_t * lv_ime_create(lv_obj_t * parent)
{
    return lv_100ask_pinyin_ime_create(parent);
}


void lv_ime_set_dict(lv_obj_t * obj, lv_100ask_dict_t * dict)
{
    return lv_100ask_pinyin_ime_set_dict(obj,dict);
}



lv_obj_t * lv_ime_get_kb(lv_obj_t * obj)
{
    return lv_100ask_pinyin_ime_get_kb(obj);
}



lv_obj_t * lv_ime_get_cand_panel(lv_obj_t * obj)
{
    return lv_100ask_pinyin_ime_get_cand_panel(obj);
}



lv_100ask_dict_t * lv_ime_get_dict(lv_obj_t * obj)
{
    return lv_100ask_pinyin_ime_get_dict(obj);
}
